package unamur.iodass.app;


import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import unamur.iodass.communication.Communication;
import unamur.iodass.communication.messages.ParcelDelivery;




public class Main {
	private static final Logger logger = Logger.getLogger(Main.class);

	public static void main(String[] args) {
		
		ProjectProperties properties = new ProjectProperties();
		
		PropertyConfigurator.configure(ProjectProperties.getProjectProperty("log4jPath"));
		
		Communication com = Communication.getInstance();
		com.startServer();

		ParcelDelivery delivery = new ParcelDelivery(
				properties.getProjectProperty("nameParcelDelivery"),
				properties.getProjectProperty("ipParcelDelivery"),
				Integer.valueOf(properties.getProjectProperty("portParcelDelivery")));
		
		
		logger.info("/**************************************");
		logger.info("             PARCEL_DELIVER            ");
		logger.info("NAME = " + delivery.getName());
		logger.info("IP = " + delivery.getIp());
		logger.info("PORT = " + delivery.getPort());
		logger.info("/**************************************");
		
		Communication.getInstance().async(
				delivery, 
				properties.getProjectProperty("ipOnlineLibrary"), 
				Integer.valueOf(properties.getProjectProperty("portOnlineLibrary")));

	}

}
